<?php //由ThinkphpHelper自动生成,请根据需要修改
namespace Test\Controller;

class ChannelController extends  {

	public function add(){
	if(IS_POST){
		$channelModel = M('Channel');
		$channelModel ->create();
		$flag = $channelModel ->add();
		if($flag){
			$this->success('新建成功',U('Channel/all')); 
		}else{
			$this->error('新建失败',U('Channel/all')); 
		}
	}else{
		$this->display(); 
	}
}

public function delete(){
	$channelModel = M('channel');
	$id = I('id'); 
	$flag = $channelModel->where('id='.$id)->delete();
	if($flag){
		$this->success('删除成功', U('Channel/all'));
	}else{
		$this->error('删除失败', U('Channel/all'));
	}
}

public function edit(){
	$channelModel = M('Channel');
	if(IS_POST){
		$channelModel ->create();
		$flag = $channelModel ->save();
		if($flag){
			$this->success('编辑成功',U('Channel/all')); 
		}else{
			$this->error('编辑失败',U('Channel/all')); 
		}
	}else{
		$id = I('id'); 
		$channel = $channelModel->find($id);
		$this->assign('channel', $channel);
		$this->display();
	}
}

public function index()
{
    $map = $this->_search();
    $channelList = $this->lists($this->model, $map);
    $this->assign('channelList', $channelList);
    $this->display();
}


}